//
//  ChildListCell.m
//  XMLY
//
//  Created by lanou on 15/11/4.
//  Copyright © 2015年 曾杰. All rights reserved.
//

#import "ChildListCell.h"

@implementation ChildListCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, SCREEN_WIDTH - 110, 30)];
        _titleLabel.font = [UIFont systemFontOfSize: 14];
        [self.contentView addSubview:_titleLabel];
        
        self.tingImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 50, 30, 30)];
        _tingImageView.image = [UIImage imageNamed:@"erji"];
        [self.contentView addSubview:_tingImageView];
        
        self.tingCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 50, 80, 30)];
        _tingCountLabel.font = [UIFont systemFontOfSize:12];
        _tingCountLabel.alpha = 0.6;
        [self.contentView addSubview:_tingCountLabel];
        
        self.timeImageView = [[UIImageView alloc] initWithFrame:CGRectMake(120, 55, 20, 20)];
        _timeImageView.image = [UIImage imageNamed:@"shijian"];
        [self.contentView addSubview:_timeImageView];
        
        self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(140, 50, 80, 30)];
        _timeLabel.font = [UIFont systemFontOfSize:12];
        _timeLabel.alpha = 0.6;
        [self.contentView addSubview:_timeLabel];
        
      
    }
    return self;
}

- (void)configureCellWithModel:(ChildListModel *)model{
    _titleLabel.text = model.title;
    if (model.playtimes >= 10000 && model.playtimes < 100000000) {
        _tingCountLabel.text = [NSString stringWithFormat:@"%.1f万", model.playtimes / 10000];
        
    }else if (model.playtimes >= 100000000){
         _tingCountLabel.text = [NSString stringWithFormat:@"%.1f亿", model.playtimes / 100000000];
    }else{
        _tingCountLabel.text = [NSString stringWithFormat:@"%.0f", model.playtimes];
    }
    _timeLabel.text = [[NSString stringWithFormat:@"%02ld", (NSInteger)model.duration / 60] stringByAppendingString:[NSString stringWithFormat:@":%02ld", (NSInteger)model.duration % 60]];

}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
